/* ************************************** JAVASCRIPT VALIDATION FILE ******************************************************* */

/**
 * Validation
 *
 * @package    ice antares
 * @author     Jonathan Olger Nieto Lajo <jonathan_nieto@hotmail.com>
 */
 
function Validation(){
}

  /**
   * Validates the range of two dates.
   *
   * @param string $from Date in format 'yyyy-mm-dd'
   * @param string $to   Date in format 'yyyy-mm-dd'
   *
   * @return bool  If $from is a date before $to
   */
  Validation.dateRange = function(from, to)
  {
    aFrom = Array();
    aFrom[0] = from.substring(0, 4);
	aFrom[1] = from.substring(5, 7);
	aFrom[2] = from.substring(8, 10);
	aTo = Array();
	aTo[0]   = to.substring(0, 4);
	aTo[1]   = to.substring(5, 7);
	aTo[2]   = to.substring(8, 10);
	
	if (aFrom[0] < aTo[0])
	{
  	  return true;
	}
	else if (aFrom[0] == aTo[0])
	{
	  if (aFrom[1] < aTo[1])
	  {
	    return true;
	  }
	  else if (aFrom[1] == aTo[1])
	  {
	    if (aFrom[2] <= aTo[2])
	    {
		  return true;
		}
	  }
	}
	
	return false;
  }
  //*** POCH 2009-03-04 ***//
  Validation.MonthDayRange = function(from, to)
  {
    aFrom = Array();
    aFrom[0] = from.substring(0, 2);
	aFrom[1] = from.substring(3, 5);
    /*aFrom[0] = from.substring(0, 4);
	aFrom[1] = from.substring(5, 7);
	aFrom[2] = from.substring(8, 10);*/
	aTo = Array();
	aTo[0]   = to.substring(0, 2);
	aTo[1]   = to.substring(3, 5);
	/*aTo[0]   = to.substring(0, 4);
	aTo[1]   = to.substring(5, 7);
	aTo[2]   = to.substring(8, 10);*/
	
	if (aFrom[0] < aTo[0])
	{
  	  return true;
	}
	else if (aFrom[0] == aTo[0])
	{
	  if (aFrom[1] < aTo[1])
	  {
	    return true;
	  }
	}
	
	return false;
  }
  //***  ***//
/**************************************************************************************************************/


